@import "./variables";

.#{$component-prefix}loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: $loading-color;

  &__spinner,
  &__circular {
    position: relative;
    box-sizing: border-box;
    width: $loading-size;
    max-width: 100%;
    height: $loading-size;
    max-height: 100%;
  }

  &__spinner {
    animation: #{$component-prefix}-rotate $loading-animation-duration steps(12) infinite;

    &__item {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;

      &::before {
        display: block;
        width: 2px * $hd;
        height: 25%;
        margin: 0 auto;
        content: ' ';
        background-color: currentColor;
        border-radius: 40%;
      }

      // Generate 12 item
      @for $i from 1 through 12 {
        &:nth-of-type(#{$i}) {
          opacity: 1 - calc(0.75 / 12) * ($i - 1);
          transform: rotate($i * 30deg);
        }
      }
    }
  }

  &__circular {
    border: $loading-circular-border-width solid transparent;
    border-top-color: currentColor;
    border-radius: 100%;
    animation: #{$component-prefix}-rotate $loading-animation-duration linear infinite;
  }

  &__text {
    margin-left: var(--padding-xs, $padding-xs);
    font-size: $loading-text-font-size;
    line-height: $loading-text-line-height;
    color: $loading-text-color;

    &:empty {
      display: none;
    }
  }

  &--vertical {
    flex-direction: column;

    .#{$component-prefix}loading__text {
      margin: var(--padding-xs, $padding-xs) 0 0;
    }
  }
}
